
package net.acoder.util;

import java.util.Scanner;

public class ScannerUtil {

    public static String getNext(String tip) {
        return getScanner(tip).next();
    }

    public static String getLine(String tip) {
        return getScanner(tip).nextLine();
    }

    public static int getInt(String tip) {
        return getScanner(tip).nextInt();
    }

    public static byte getByte(String tip) {
        return getScanner(tip).nextByte();
    }

    public static long getLong(String tip) {
        return getScanner(tip).nextLong();
    }

    public static char getChar(String tip) {
        return getScanner(tip).next().charAt(0);
    }

    public static boolean getBoolean(String tip) {
        return getScanner(tip).nextBoolean();
    }

    public static float getFloat(String tip) {
        return getScanner(tip).nextFloat();
    }

    public static double getDouble(String tip) {
        return getScanner(tip).nextDouble();
    }

    public static short getShort(String tip) {
        return getScanner(tip).nextShort();
    }

    private static Scanner getScanner(String tip) {
        if (tip != null && tip.length() > 0) {
            System.out.print(tip);
        }
        return new Scanner(System.in);
    }
}
